package com.mf.controller.threadPool;

import io.swagger.v3.oas.annotations.Operation;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @Author: lmf
 * @Create: 2025/5/28 21:49
 * @module 固定线程池使用
 * @Description: 这个线程池的特别是线程数是固定的。
 */
@RestController
@RequestMapping("/newFixedThreadPool")
public class newFixedThreadPool {
    ExecutorService threadPool = Executors.newFixedThreadPool(3);

    @RequestMapping("/test")
    @Operation(summary = "固定线程数执行")
    public void test() {
        for (int i = 0; i < 10; i++) {
            threadPool.execute(() -> {
                System.out.println(Thread.currentThread().getName() + "正在执行");
            });
        }
    }
}
